<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>摊位转租</title>
<%@ include file="../inc.jsp"%>

</head>

<body class="easyui-layout">

	<div data-options="region:'north',border:false"
		style="height: 80px; overflow: hidden; padding: 0px">
		<form action="" method="post" id="searchForm">
			<div style="margin-left: 10px; margin-top: 10px;">
				所属人名称:&nbsp;<input class="easyui-validatebox textbox" id="userName"
					name=""userName"" maxlength="100" style="width: 160px">&nbsp;&nbsp;&nbsp;
				摊位状态:&nbsp;<select class="easyui-combobox" id="boothStatus"
					name="boothStatus" style="width: 150px;" data-options="height:'22px'">
					<option value="">全部</option>
					<option value="0">启用</option>
					<option value="1">禁用</option>
				</select>
					&nbsp;&nbsp;&nbsp; 经营时间:&nbsp;<input class="easyui-datebox"
						id="businessStartTime" name="businessStartTime" data-options="height:'22px'"></input>
					&nbsp;至&nbsp; <input class="easyui-datebox" id="businessEndTime"
						name="businessEndTime" data-options="height:'22px'"></input> &nbsp;&nbsp;&nbsp; <a
						href="javascript:void(0)" class="easyui-linkbutton"
						iconCls="icon-search" onclick="find()">查询</a>

			</div>
		</form>
	</div>

	<div data-options="region:'center',border:false">
		<table id="dg" class="easyui-datagrid" title="摊位经营户信息列表" fit="true"
			style="width: 700px; height: 250px"
			data-options="rownumbers:true,singleSelect:true,url:'${baseUrl }/admin/boothSublet/list',method:'post',toolbar:'#toolbar',
			showFooter:false,pagination:true,idField:'id'">
			<thead>
				<tr>
					<th data-options="field:'user_name',width:150,align:'center'">所属人名称</th>
					<th data-options="field:'phone',width:150,align:'center'">电话</th>
					<th data-options="field:'booth_name',width:150,align:'center'">摊位名称</th>
					<th data-options="field:'booth_status',width:130,align:'center',formatter:showStatus">摊位状态</th>
					<th data-options="field:'num',width:150,align:'center'">摊位号码</th>
					<th data-options="field:'area',width:150,align:'center'">摊位面积</th>
					<th data-options="field:'address',width:150,align:'center'">摊位地址</th>
					<th data-options="field:'business_start_time',width:200,align:'center'">开始经营时间</th>
					<th data-options="field:'business_end_time',width:200,align:'center'">结束经营时间</th>
				</tr>
			</thead>
		</table>
		<!-- 功能菜单 -->
		<div id="toolbar" style="display: none;" align="left"></div>
	</div>
</body>
<script type="text/javascript">
      const groupMenu = {
      		2: [{name: '启用',icon: 'icon-open',callFun: 'open_disabled_fun(0)',id:'open'}
      			,{name: '禁用',icon: 'icon-disabled',callFun: 'open_disabled_fun(1)',id:'disabled'}
      			,{name: '转租',icon: 'icon-sublet',callFun: 'sublet_fun()',id:'pay'}
      			,{name: '清空条件',icon: 'icon-remove',callFun: 'reset_fun()',id:'remove'}
      			]
      }
      $(document).ready(function(){
      	//var groupType = ${sessionScope.user.group_type}
      	var btnArr = groupMenu[2]
      	console.log('btnArr',btnArr)
      	$('#toolbar').html('')
      	if(btnArr && btnArr.length > 0){
      		btnArr.forEach(function(item){
      			var html = '<a href="javascript:void(0);" class="easyui-linkbutton showBtn l-btn l-btn-plain" data-options="iconCls:'+item.icon+',plain:true" onclick="'+item.callFun+'" group="" id="'+item.id+'"><span class="l-btn-left"><span class="l-btn-text '+item.icon+' l-btn-icon-left">'+item.name+'</span></span></a>';
      			$('#toolbar').append(html);
      		})
      	}
      })
      function open_disabled_fun(flag){
    	  var row = $('#dg').datagrid('getSelected');
          if(!row)
          {
              $.messager.alert("提示","请选择！",'info');
          }
          else
          {
        	  $.messager.confirm("提示","确认该操作？",function(conf){
                  if(conf)
                  {
                      var url = "${baseUrl}/admin/boothSublet/doOpenDisable?boothStatus="+flag+"&selectId="+row.id;
                      $.getJSON(url, function(json){
                          if(json.success==0)
                          {
                          	$('#dg').datagrid('reload');
                          }
                          else
                          {
                              showErrMsg(json);
                          }
                      });
                  }                                       
              });
          }
      }
      function sublet_fun()
      {
    	  
    	  var row = $('#dg').datagrid('getSelected');
          if(!row)
          {
              $.messager.alert("提示","请选择！",'info');
          }
          else
          {
        	  if(row.booth_status == 0){
        		  $.messager.alert('提示','只有禁用下的摊位才能进行转租！','warning')
        		  return
        	  }
        	  var params = {
                      winId:'win_add_booth_sublet',
                      title:'添加摊位申请信息',
                      width:800,
                      height:390,
                      showUrl:'${baseUrl}/admin/boothSublet/au_page?id='+row.id,
                      refresh_fun:function(){
                          $('#dg').datagrid('reload');
                      }
                      
              };
              open_fun(params);
          }
         
      }
      function find(){
		$('#dg').datagrid('load',{
			userName:$('#userName').val(),
			boothStatus:$('#boothStatus').combobox('getValue'),
			businessStartTime:$('#businessStartTime').datetimebox('getValue'),
			businessEndTime:$('#businessEndTime').datetimebox('getValue'),
		});
	}
      function reset_fun(){
      	$('#searchForm').form('reset');
      	find();
      }
    	function showStatus(value,rec,index)
    	{
    		if(value==0)
    			return "<font color=''>启用</font>";
    		else if(value == 1)
    			return "<font color='red'>禁用</font>";
    	}
	</script>
<style type="text/css">
.showBtn {
	display: inline;
}
</style>
</html>
